package com.luwanglin.eduservice.controller;


import com.luwanglin.commonutils.R;
import com.luwanglin.eduservice.entity.EduVideo;
import com.luwanglin.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * cource subsection  课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-05-13
 */
@RestController
@RequestMapping("/eduservice/video")
public class EduVideoController {

    @Autowired
    private EduVideoService videoService;

    @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo videoInfo) {
        videoService.save(videoInfo);
        return R.ok();
    }

    @DeleteMapping("deleteVideo/{id}")
    public R deleteVideo(@PathVariable("id") String id) {
        videoService.completeDelete(id);
        return R.ok();
    }

    @GetMapping("getVideoInfo/{id}")
    public R getVideoInfo(@PathVariable("id") String videoId) {
        EduVideo video = videoService.getById(videoId);
        return R.ok().data("videoInfo", video);
    }

    @PutMapping("updateVideoInfo")
    public R updateVideoInfo(@RequestBody EduVideo videoInfo) {
        videoService.updateById(videoInfo);
        return R.ok();
    }
}

